function test(a) {
  return new Promise((resolve, reject)=>{
    console.log('///000///'+a);
    //resolve(a);
  });
}
function mergePromise2(ajaxArray) {
  let p = Promise.resolve();
  let arr = [];
  ajaxArray.forEach(promise => {
    p = p.then(promise).then((data) => {
      console.log('======'+data);
        arr.push(data);
        return arr;
    });
  });
  return p;
}

// 使用递归
function sequencePromise(arr){
   const pro = arr.shift()
   console.log('44444444');
   console.log(pro);
   if(pro) {
    pro().then((res)=>{
        sequencePromise(arr)
       })
   }else{
     wx.hideLoading();
   }
}

function downloadFile(url){
  return new Promise((resolve, reject)=>{
    wx.downloadFile({
      url: url,
       success:function(res){
         console.log(res);
        resolve(res);
      },fail:function(res){
        reject(res);
      }
    })
  });
}
async function getDownloadFiles(array){
  console.log(array.length)
  for(let arr of array){
    var res=await arr;
    console.log('-----------res1-----------');
    console.log(res);
  }
  return await res;
}
module.exports = {
  downloadFile,
  getDownloadFiles,
  test,
  mergePromise2,
  sequencePromise
}
